#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl/point_cloud.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/visualization/cloud_viewer.h>

static pcl::visualization::CloudViewer viewer("point cloud");

void laserCallback(sensor_msgs::PointCloud2ConstPtr msg)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr lasercloud(new pcl::PointCloud<pcl::PointXYZ>);
  pcl::fromROSMsg(*msg, *lasercloud);
  viewer.showCloud(lasercloud);
  return;
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "show_point_cloud_using_pcl");
  ros::NodeHandle nh;
  ros::Subscriber pcl_sub = nh.subscribe("/rslidar_points", 10, laserCallback);

  ros::spin();
  return 0;
}